/*************************************************************************
    > File Name: clock.h
    > Author: fanzhihui
    > Mail: 953106194@qq.com 
    > Created Time: 2019年06月25日 星期二 11时25分49秒
 ************************************************************************/
#ifndef __FHTTPD_CLOCK_H_
#define __FHTTPD_CLOCK_H_
#include<iostream>
#include "log/logger.h"
using namespace std;
class Clock
{
public:
	Clock(const std::string& name)
	{
		classFuncName = name;
		p0 = std::chrono::high_resolution_clock::now();
	}
	virtual ~Clock()
	{
		p1 = std::chrono::high_resolution_clock::now();
	
		std::cout << classFuncName <<" clock time:" <<
		(float)std::chrono::duration_cast<std::chrono::microseconds>(p1 - p0).count() / 1000 << std::endl;

		LOG( LOG_DEBUG, "%s clock time:%f",classFuncName.c_str(), (float)std::chrono::duration_cast<std::chrono::microseconds>(p1 - p0).count() / 1000 );
	}

protected:
    std::chrono::time_point<std::chrono::high_resolution_clock> p0;
    std::chrono::time_point<std::chrono::high_resolution_clock> p1;

	std::string classFuncName;

	Clock(const Clock&)
	{
	}
	Clock& operator=(const Clock&)
	{
	}

};

#endif

